import Cookies from 'js-cookie'

const TokenKey = 'vue_admin_template_token'

const PermissionKey = 'permission'

const LastRouteKey = 'last_route'
export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function getPermission() {
  const permission = sessionStorage.getItem(PermissionKey);
  return permission?permission.split(','):[]
}

export function setPermission(value) {
  return sessionStorage.setItem(PermissionKey, value)
}


export function getLastRoute() {
  return sessionStorage.getItem(LastRouteKey)
}

export function setLastRoute(value) {
  return sessionStorage.setItem(LastRouteKey, value)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
